import { Entity, PrimaryGeneratedColumn, Column, OneToMany } from 'typeorm';
import { DictionaryItem } from './dictionary-item.entity';
import { ApiProperty } from '@nestjs/swagger'
@Entity('dictionary')
export class Dictionary {
    @ApiProperty({
        description: 'id', default: null, type: 'int',
        example: 1, required: false,
    })
    @PrimaryGeneratedColumn()
    id: number;

    @Column({ unique: true })
    @ApiProperty({
        description: 'type', default: null, type: 'string',
        example: '', required: false,
    })
    type: string;

    @Column()
    @ApiProperty({
        description: 'name', default: null, type: 'string',
        example: '', required: true,
    })
    name: string;
    @ApiProperty({
        description: 'description', default: null, type: 'string',
        example: '', required: false,
    })
    @Column({ nullable: true })
    description: string;

    @OneToMany(() => DictionaryItem, item => item.dictionary)
    @ApiProperty({
        description: 'items', default: null, type: 'json',
        example: '', required: false,
    })
    items: DictionaryItem[];
}